'use strict';
// npx sequelize migration:generate --name=<操作名称></操作名称>
// npx sequelize db:migrate
// npx sequelize db:migrate:undo

module.exports = {
  up: async (queryInterface, Sequelize) => {
    const { INTEGER, DATE, JSON, BOOLEAN } = Sequelize;
    await queryInterface.createTable('sessions', {
      id: { type: INTEGER, primaryKey: true, autoIncrement: true },
      user_id: { type: INTEGER },
      urls: JSON,
      isAdmin: { type: BOOLEAN, field: 'isAdmin' },
      created_at: DATE,
      updated_at: DATE,
    });
    queryInterface.addIndex('sessions', [ 'user_id' ], { unique: true });
  },

  down: async queryInterface => {
    await queryInterface.dropTable('sessions');
  },
};
